home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Tcl_SplitList C Library Procedures Tcl_SplitList
-
-
-
- _________________________________________________________________
-
- NNAAMMEE
- Tcl_SplitList, Tcl_Merge, Tcl_ScanElement,
- Tcl_ConvertElement - manipulate Tcl lists
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<ttccll..hh>>
-
- int
- TTccll__SSpplliittLLiisstt(_i_n_t_e_r_p, _l_i_s_t, _a_r_g_c_P_t_r, _a_r_g_v_P_t_r)
-
- char *
- TTccll__MMeerrggee(_a_r_g_c, _a_r_g_v)
-
- int |
- TTccll__SSccaannEElleemmeenntt(_s_r_c, _f_l_a_g_s_P_t_r) |
-
- int |
- TTccll__CCoonnvveerrttEElleemmeenntt(_s_r_c, _d_s_t, _f_l_a_g_s) |
-
- AARRGGUUMMEENNTTSS
- Tcl_Interp *_i_n_t_e_r_p (out) Interpreter to use for
- error reporting.
-
- char *_l_i_s_t (in) Pointer to a string with
- proper list structure.
-
- int *_a_r_g_c_P_t_r (out) Filled in with number of
- elements in _l_i_s_t.
-
- char ***_a_r_g_v_P_t_r (out) *_a_r_g_v_P_t_r will be filled
- in with the address of
- an array of pointers to
- the strings that are the
- extracted elements of
- _l_i_s_t. There will be
- *_a_r_g_c_P_t_r valid entries
- in the array, followed
- by a NULL entry.
-
- int _a_r_g_c (in) Number of elements in
- _a_r_g_v.
-
- char **_a_r_g_v (in) Array of strings to
- merge together into a
- single list. Each
- string will become a
- separate element of the
- list.
-
- char *_s_r_c (in) String that is to become |
-
-
-
- Sprite v1.0 1
-
-
-
-
-
-
- Tcl_SplitList C Library Procedures Tcl_SplitList
-
-
-
- an element of a list. |
-
- int *_f_l_a_g_s_P_t_r (in) ||
- Pointer to word to fill |
- in with information |
- about _s_r_c. The value of |
- *_f_l_a_g_s_P_t_r must be passed |
- to TTccll__CCoonnvveerrttEElleemmeenntt. |
-
- char *_d_s_t (in) ||
- Place to copy converted |
- list element. Must con- |
- tain enough characters |
- to hold converted |
- string. |
-
- int _f_l_a_g_s (in) ||
- Information about _s_r_c. |
- Must be value returned |
- by previous call to |
- TTccll__SSccaannEElleemmeenntt, possi- |
- bly OR-ed with |
- TTCCLL__DDOONNTT__UUSSEE__BBRRAACCEESS.
- _________________________________________________________________
-
-
- DDEESSCCRRIIPPTTIIOONN
- These procedures may be used to disassemble and reassemble
- Tcl lists. TTccll__SSpplliittLLiisstt breaks a list up into its consti-
- tuent elements, returning an array of pointers to the ele-
- ments using _a_r_g_c_P_t_r and _a_r_g_v_P_t_r. While extracting the argu-
- ments, TTccll__SSpplliittLLiisstt obeys the usual rules for backslash
- substitutions and braces. The area of memory pointed to by
- *_a_r_g_v_P_t_r is dynamically allocated; in addition to the array
- of pointers, it also holds copies of all the list elements.
- It is the caller's responsibility to free up all of this
- storage by calling
-
- ffrreeee((char *) *_a_r_g_v_P_t_r)
- when the list elements are no longer needed.
-
- TTccll__SSpplliittLLiisstt normally returns TTCCLL__OOKK, which means the list
- was successfully parsed. If there was a syntax error in
- _l_i_s_t, then TTCCLL__EERRRROORR is returned and _i_n_t_e_r_p->_r_e_s_u_l_t will
- point to an error message describing the problem. If
- TTCCLL__EERRRROORR is returned then no memory is allocated and
- *_a_r_g_v_P_t_r is not modified.
-
- TTccll__MMeerrggee is the inverse of TTccll__SSpplliittLLiisstt: it takes a col-
- lection of strings given by _a_r_g_c and _a_r_g_v and generates a
- result string that has proper list structure. This means
- that commands like iinnddeexx may be used to extract the original
-
-
-
- Sprite v1.0 2
-
-
-
-
-
-
- Tcl_SplitList C Library Procedures Tcl_SplitList
-
-
-
- elements again. In addition, if the result of TTccll__MMeerrggee is
- passed to TTccll__EEvvaall, it will be parsed into _a_r_g_c words whose
- values will be the same as the _a_r_g_v strings passed to
- TTccll__MMeerrggee. TTccll__MMeerrggee will modify the list elements with
- braces and/or backslashes in order to produce proper Tcl
- list structure. The result string is dynamically allocated
- using mmaalllloocc(()); the caller must eventually release the
- space using ffrreeee(()).
-
- If the result of TTccll__MMeerrggee is passed to TTccll__SSpplliittLLiisstt, the
- elements returned by TTccll__SSpplliittLLiisstt will be identical to
- those passed into TTccll__MMeerrggee. However, the converse is not
- true: if TTccll__SSpplliittLLiisstt is passed a given string, and the
- resulting _a_r_g_c and _a_r_g_v are passed to TTccll__MMeerrggee, the result-
- ing string may not be the same as the original string passed
- to TTccll__SSpplliittLLiisstt. This is because TTccll__MMeerrggee may use
- backslashes and braces differently than the original string.
-
- TTccll__SSccaannEElleemmeenntt and TTccll__CCoonnvveerrttEElleemmeenntt are the procedures |
- that do all of the real work of TTccll__MMeerrggee. TTccll__SSccaannEElleemmeenntt |
- scans its _s_r_c argument and determines how to use backslashes |
- and braces when converting it to a list element. It returns |
- an overestimate of the number of characters required to |
- represent _s_r_c as a list element, and it stores information |
- in *_f_l_a_g_s_P_t_r that is needed by TTccll__CCoonnvveerrttEElleemmeenntt. |
-
- TTccll__CCoonnvveerrttEElleemmeenntt is a companion procedure to |
- TTccll__SSccaannEElleemmeenntt. It does the actual work of converting a |
- string to a list element. Its _f_l_a_g_s argument must be the |
- same as the value returned by TTccll__SSccaannEElleemmeenntt. |
- TTccll__CCoonnvveerrttEElleemmeenntt writes a proper list element to memory |
- starting at *_d_s_t and returns a count of the total number of |
- characters written, which will be no more than the result |
- returned by TTccll__SSccaannEElleemmeenntt. TTccll__CCoonnvveerrttEElleemmeenntt writes out |
- only the actual list element without any leading or trailing |
- spaces: it is up to the caller to include spaces between |
- adjacent list elements. |
-
- TTccll__CCoonnvveerrttEElleemmeenntt uses one of two different approaches to |
- handle the special characters in _s_r_c. Wherever possible, it |
- handles special characters by surrounding the string with |
- braces. This produces clean-looking output, but can't be |
- used in some situations, such as when _s_r_c contains unmatched |
- braces. In these situations, TTccll__CCoonnvveerrttEElleemmeenntt handles |
- special characters by generating backslash sequences for |
- them. The caller may insist on the second approach by OR- |
- ing the flag value returned by TTccll__SSccaannEElleemmeenntt with |
- TTCCLL__DDOONNTT__UUSSEE__BBRRAACCEESS. Although this will produce an uglier |
- result, it is useful in some special situations, such as |
- when TTccll__CCoonnvveerrttEElleemmeenntt is being used to generate a portion |
- of an argument for a Tcl command. In this case, surrounding |
- _s_r_c with curly braces would cause the command not to be |
-
-
-
- Sprite v1.0 3
-
-
-
-
-
-
- Tcl_SplitList C Library Procedures Tcl_SplitList
-
-
-
- parsed correctly.
-
-
- KKEEYYWWOORRDDSS
- backslash, convert, element, list, merge, split, strings
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Sprite v1.0 4
-
-
-
-